package com.crrc.yzt.demo.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.crrc.yzt.demo.blue.R
import com.crrc.yzt.demo.blue.databinding.ItemValue2Binding

class ValueAdapter3 : RecyclerView.Adapter<ValueViewHolder3>() {

    val data = mutableListOf<String>()

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ValueViewHolder3 {
        val itemBinding: ItemValue2Binding = ItemValue2Binding.inflate(LayoutInflater.from(parent.context),parent,false)
        return ValueViewHolder3(itemBinding)
    }

    override fun getItemCount(): Int {
        return data.size
    }

    override fun onBindViewHolder(holder: ValueViewHolder3, position: Int) {
        holder.itemBinding.tvValue.text = data[position]
        holder.itemBinding.tvDetail.visibility = View.GONE
        when(position){
            0->holder.itemBinding.ivIcon.setImageResource(R.drawable.check1)
            1->holder.itemBinding.ivIcon.setImageResource(R.drawable.check2)
            2->{
                holder.itemBinding.ivIcon.setImageResource(R.drawable.check3)
            }
            3->holder.itemBinding.ivIcon.setImageResource(R.drawable.check4)
            4->holder.itemBinding.ivIcon.setImageResource(R.drawable.check5)
            5->{
                holder.itemBinding.ivIcon.setImageResource(R.drawable.check6)
                holder.itemBinding.ivState.setImageResource(R.drawable.check_error)
                holder.itemBinding.tvState.text = "이상"
                holder.itemBinding.tvDetail.visibility = View.VISIBLE
            }
        }
    }
}

class ValueViewHolder3(val itemBinding: ItemValue2Binding) : RecyclerView.ViewHolder(itemBinding.root) {

}